package com.test.common;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

/**
 * 配置文件加密处理
 * @author Administrator
 *
 */

public class EncryptPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
	
	private String[] propertyNames = { "jdbc.password" };

	/**
	 * 解密指定propertyName的加密属性值
	 * 
	 * @param propertyName
	 * @param propertyValue
	 * @return
	 */
	@Override
	protected String convertProperty(String propertyName, String propertyValue) {
		for (String p : propertyNames) {
			if (p.equalsIgnoreCase(propertyName)) {
				return AESUtil.aesDecode(propertyValue);
			}
		}
		return super.convertProperty(propertyName, propertyValue);
	}
}
